import axios from 'axios'

const BASE = 'http://127.0.0.1:8888/api/private/v1/'

// 获取商品列表请求
export const getGoodsList = queryInfo => {
  return axios.get(BASE + 'goods', { params: queryInfo })
}

// 删除商品请求
export const deleteGoods = id => {
  return axios.delete(BASE + `goods/${id}`)
}

// 添加分类参数请求
export const cateCel = (id, attrid, obj) => {
  return axios.put(BASE + `categories/${id}/attributes/${attrid}`, obj)
}

// 获取商品分类请求
export const getGoodsCategory = () => {
  return axios.get(BASE + 'categories')
}

// 获取商品参数请求
export const getGoodsAttributtes = (id, sel) => {
  return axios.get(BASE + `categories/${id}/attributes`, { params: { sel: sel } })
}

// 添加商品请求
export const addGoodsReq = form => {
  return axios.post(BASE + 'goods', form)
}

// 根据 id 查询商品
export const queryGoodsById = id => {
  return axios.get(BASE + `goods/${id}`)
}

// 编辑商品请求
export const editGoodsReq = (form, id) => {
  return axios.put(BASE + `goods/${id}`, form)
}
